import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

const login = r => require.ensure([], () => r(require('@/page/login')), 'login');
const manage = r => require.ensure([], () => r(require('@/page/manage')), 'manage');
const home = r => require.ensure([], () => r(require('@/page/home')), 'home');
const userList = r => require.ensure([], () => r(require('@/page/userList')), 'userList');
const questionDetail = r => require.ensure([], () => r(require('@/page/questionDetail')), 'questionDetail');
const adminList = r => require.ensure([], () => r(require('@/page/adminList')), 'adminList');
const visitor = r => require.ensure([], () => r(require('@/page/visitor')), 'visitor');
const vueEdit = r => require.ensure([], () => r(require('@/page/vueEdit')), 'vueEdit');
const adminSet = r => require.ensure([], () => r(require('@/page/adminSet')), 'adminSet');
const explain = r => require.ensure([], () => r(require('@/page/explain')), 'explain');
const openNews = r => require.ensure([], () => r(require('@/page/openNews')), 'openNews');

const routes = [
	{
		path: '/',
		component: login
	},
	{
		path: '/manage',
		component: manage,
		name: '',
		children: [{
			path: '',
			component: home,
			meta: [],
		},{
			path: '/userList',
			component: userList,
			meta: ['用户列表'],
		},{
			path: '/questionDetail',
			component: questionDetail,
			meta: ['用户列表', '答题人详情']
		},{
			path: '/adminList',
			component: adminList,
			meta: ['管理员列表'],
		},{
			path: '/visitor',
			component: visitor,
			meta: ['答题列表'],
		},{
			path: '/vueEdit',
			component: vueEdit,
			meta: ['编辑', '文本编辑'],
		},{
			path: '/adminSet',
			component: adminSet,
			meta: ['设置', '管理员设置'],
		},{
			path: '/explain',
			component: explain,
			meta: ['说明', '说明'],
        },
        {
			path: '/openNews',
			component: openNews,
			meta: ['开通权限', '填写账号信息'],
		}]
	}
]

export default new Router({
	routes,
	strict: process.env.NODE_ENV !== 'production',
})
